# -*- coding=utf-8 -*-

'''
代理网站：西刺代理：http://www.xicidaili.com/
参考网站：http://blog.csdn.net/willib/article/details/52374507
'''

import requests
import re

def regex_string(content):
    pattern = '<title>(.*?)</title>'
    return re.compile(pattern).findall(content)

def without_proxy():
    request_body=requests.get('http://www.baidu.com')
    page_content_decode=request_body.content.decode("utf-8")
    title =regex_string(page_content_decode)
    return title

def with_proxy():
    proxies = {
        "http": "http://115.183.11.158:9999",
        "https": "http://116.248.162.15:80"
    }

    request_body=requests.get("http://www.baidu.com", proxies=proxies)
    print(request_body.content.decode("utf-8"))

if __name__=='__main__':
    #print(without_proxy())
    print(with_proxy())